package cn.studyjams.s1.contest.autohello;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import cn.studyjams.s1.contest.autohello.adapter.ExecuteLogAdapter;
import cn.studyjams.s1.contest.autohello.model.ExecuteLog;

public class ExecuteLogFragment extends Fragment {

    List<ExecuteLog> mDataset;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_recent, container, false);

        RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recent_recycler_view);
        recyclerView.setHasFixedSize(true);
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
        recyclerView.setLayoutManager(layoutManager);

        mDataset = initDataset();
        if (mDataset.size() == 0) {
            view.findViewById(R.id.empty_recent).setVisibility(View.VISIBLE);
        }

        RecyclerView.Adapter adapter = new ExecuteLogAdapter(mDataset);
        recyclerView.setAdapter(adapter);

        return  view;
    }

    private List<ExecuteLog> initDataset() {
        return new ArrayList<>();
    }
}
